﻿using System;
using System.Web.Mvc;

namespace Avalon.Core.MVC.Attributes
{
    [AttributeUsage(AttributeTargets.Property)]
    public class RenderTypeAttribute : Attribute, IMetadataAware
    {
        public const string Key = "ViewType";
        public ViewType ViewType { get; set; }

        public bool AllowAdd { get; set; }
        public bool AllowDelete { get; set; }

        public RenderTypeAttribute(ViewType viewType)
        {
            ViewType = viewType;
            AllowAdd = false;
            AllowDelete = false;
        }

        public void OnMetadataCreated(ModelMetadata metadata)
        {
            metadata.AdditionalValues[Key] = this;
        }
    }

    public enum ViewType
    {
        CollationView = 0,
        CustomView = 1,
        GridView = 2,
        ReportView = 3,
        SimpleView = 4
    }
}
